//
//  CmtAttenCellTableViewCell.m
//  Products_B
//
//  Created by lanou on 16/5/28.
//  Copyright © 2016年 朋学友. All rights reserved.
//

#import "CmtAttenCellTableViewCell.h"
#import "CmtRecommendLike.h"
#import "CmtSecMoreLikeViewController.h"

@interface CmtAttenCellTableViewCell ()

@property (weak, nonatomic) IBOutlet UILabel *agree_count;

@property (weak, nonatomic) IBOutlet UILabel *comment_count;

@property(nonatomic,strong)NSString *_id;

@end

@implementation CmtAttenCellTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.BigView.userInteractionEnabled = YES;
        
        self.head_img.userInteractionEnabled = YES;
        self.image1.userInteractionEnabled = YES;
        self.image2.userInteractionEnabled = YES;
        self.image3.userInteractionEnabled = YES;
        self.image4.userInteractionEnabled = YES;
        self.image5.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(CmtAttenCellTap:)];
        UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(CmtAttenCellTap:)];
            UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(CmtAttenCellTap:)];
            UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(CmtAttenCellTap:)];
            UITapGestureRecognizer *tap4 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(CmtAttenCellTap:)];
            UITapGestureRecognizer *tap5 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(CmtAttenCellTap:)];
        
            [self.head_img addGestureRecognizer:tap];
        [self.image1 addGestureRecognizer:tap1];
            [self.image2 addGestureRecognizer:tap2];
            [self.image3 addGestureRecognizer:tap3];
            [self.image4 addGestureRecognizer:tap4];
            [self.image5 addGestureRecognizer:tap5];

        [self.head_img addGestureRecognizer:tap];
    }
    return self;
}

-(void)CmtAttenCellTap:(UITapGestureRecognizer *)tap{

    NSLog(@"点击了轻扫手势");
}

-(void)setModel:(CmtRecommendModel *)model{

    self._id = model._id;
    [self.coverimg sd_setImageWithURL:[NSURL URLWithString:[model.image stringByReplacingOccurrencesOfString:@"\\" withString:@""]]];
    [self.head_img sd_setImageWithURL:[NSURL URLWithString:[model.head_img  stringByReplacingOccurrencesOfString:@"\\" withString:@""]]];
    self.time.text = model.create_time;
    self.title.text = model.nick;
    
    self.agree_count.text = [NSString stringWithFormat:@"%@",model.agree_count];
//    NSLog(@"%@",model.agree_count);
    self.comment_count.text = [NSString stringWithFormat:@"%@",model.comment_count];
   

    if (model.like.count == 0) {
        return;
    }
    
    NSDictionary *ctmodel1 = model.like[0];
    NSString *str1 = ctmodel1[@"head_img"];
    [self.image1 sd_setImageWithURL:[NSURL URLWithString:[str1 stringByReplacingOccurrencesOfString:@"\\" withString:@""]]];
    
    NSDictionary *ctmodel2 = model.like[1];
    NSString *str2 = ctmodel2[@"head_img"];
    [self.image2 sd_setImageWithURL:[NSURL URLWithString:[str2 stringByReplacingOccurrencesOfString:@"\\" withString:@""]]];
    
    NSDictionary *ctmodel3 = model.like[2];
    NSString *str3 = ctmodel3[@"head_img"];
    [self.image3 sd_setImageWithURL:[NSURL URLWithString:[str3 stringByReplacingOccurrencesOfString:@"\\" withString:@""]]];
    
    NSDictionary *ctmodel4 = model.like[3];
    NSString *str4 = ctmodel4[@"head_img"];
    [self.image4 sd_setImageWithURL:[NSURL URLWithString:[str4 stringByReplacingOccurrencesOfString:@"\\" withString:@""]]];
    
    NSDictionary *ctmodel5 = model.like[4];
    NSString *str5 = ctmodel5[@"head_img"];
    [self.image5 sd_setImageWithURL:[NSURL URLWithString:[str5 stringByReplacingOccurrencesOfString:@"\\" withString:@""]]];

}

- (IBAction)MoreCommentBtnAction:(id)sender {
    NSLog(@"点击了更多按钮");
}


- (IBAction)praiseAction:(id)sender {
    
     NSLog(@"点击了赞");
}


- (IBAction)commentAction:(id)sender {
     NSLog(@"点击了评论按钮");
}

- (IBAction)shareAction:(id)sender {
     NSLog(@"点击了分享按钮");
}



- (IBAction)moreCommentLike:(id)sender {
    
    NSLog(@"点击了更多赞");
    
    self.cellblock(self._id);
}



- (void)awakeFromNib {
    // Initialization code
    
    self.model = [[CmtRecommendModel alloc]init];
    
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
